package com.example.widgetevent;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class TextActivity extends Activity {
	
	//레이아웃에 배치된 위젯을 다루기 위해
	//위젯에 대한 변수를 선언함
	private EditText normalText;
	private EditText nameText;
	private EditText pwText;
	private EditText nPwText;
	private EditText emailText;
	private EditText phoneText;
	private EditText addText;
	private EditText moreText;
	
	
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_text);
		
		//멤버변수로 선언한 위젯 변수에  객체를 정의
		//레이아웃에 배치된 위젯을 지정하려면
		//findViewById()메소드를 사용함
		//위젯의 id는 R.java의 이름을 참고함
		normalText = (EditText)findViewById(R.id.normalText);
		nameText = (EditText)findViewById(R.id.nameText);
		pwText = (EditText)findViewById(R.id.pwText);
		nPwText = (EditText)findViewById(R.id.nPwText);
		emailText = (EditText)findViewById(R.id.emailText);
		phoneText = (EditText)findViewById(R.id.phoneText);
		addText = (EditText)findViewById(R.id.addText);
		moreText = (EditText)findViewById(R.id.moreText);
		
	}
	
	//입력내용 클릭 이벤트 처리용 메소드
	public void showInput(View v){
		StringBuilder sb = new StringBuilder();
		
		sb.append(normalText.getText()).append("\n");
		sb.append(nameText.getText()).append("\n");
		sb.append(pwText.getText()).append("\n");
		sb.append(nPwText.getText()).append("\n");
		sb.append(emailText.getText()).append("\n");
		sb.append(phoneText.getText()).append("\n");
		sb.append(addText.getText()).append("\n");
		sb.append(moreText.getText()).append("\n");
		
		Toast.makeText(getApplicationContext(), sb.toString(), Toast.LENGTH_LONG).show();
	}
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.text, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
